{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fa fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post" enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="box-body">
                        <div class="form-group">
                            <label for="username" class="col-sm-2 control-label">用户名</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="username" name="username" value="{$data.username|default=''}" placeholder="请输入用户名" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="password" class="col-sm-2 control-label">密码</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="password" name="password" value="{$data.password|default=''}" placeholder="请输入密码" type="password" class="form-control field-password">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="avatar" class="col-sm-2 control-label">头像</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="avatar" name="avatar"  placeholder="请上传头像" data-initial-preview="{$data.avatar|default=''}" type="file" class="form-control field-image" >
                            </div>
                        </div>
                        <script>
                            $('#avatar').fileinput({
                                language: 'zh',
                                overwriteInitial: true,
                                browseLabel: '浏览',
                                initialPreviewAsData: true,
                                dropZoneEnabled: false,
                                showUpload:false,
                                showRemove: false,
                                allowedFileTypes:['image'],
                                maxFileSize:10240,
                            });
                        </script>
                        <div class="form-group">
                            <label for="mobile" class="col-sm-2 control-label">手机号</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="mobile" name="mobile" value="{$data.mobile|default=''}" placeholder="请输入手机号" type="tel" maxlength="11" class="form-control field-mobile">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="qq" class="col-sm-2 control-label">qq</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="qq" name="qq" value="{$data.qq|default=''}" placeholder="请输入qq" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="email" class="col-sm-2 control-label">邮箱</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="email" name="email" value="{$data.email|default=''}" placeholder="请输入邮箱" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="user_money" class="col-sm-2 control-label">金币余额</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="user_money" name="user_money" value="{$data.user_money|default='0.00'}" placeholder="请输入金币余额" type="text" class="form-control" readonly>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 表单底部 -->
                    <div class="box-footer">
                        {:token()}
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            {if !isset($data)}
                            <div class="btn-group pull-right">
                                <label class="createContinue">
                                    <input type="checkbox" value="1" id="_create" name="_create"
                                           title="继续添加数据">继续添加</label>
                            </div>
                            {/if}
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    保存
                                </button>
                            </div>
                            <div class="btn-group">
                                <button type="reset" class="btn flat btn-default dataFormReset">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
            'username': {
                required: true,
            },
            'password': {
                required: true,
            },
            'mobile': {
                required: true,
            },
            'qq': {
                required: true,
            },
            'email': {
                required: true,
            },
            'user_money': {
                required: true,
            },

        },
        messages: {
            'username': {
                required: "用户名不能为空",
            },
            'password': {
                required: "密码不能为空",
            },
            'mobile': {
                required: "手机号不能为空",
            },
            'qq': {
                required: "qq不能为空",
            },
            'email': {
                required: "邮箱不能为空",
            },
            'user_money': {
                required: "金币余额不能为空",
            },

        }
    });
</script>
{/block}